package com.syscom.admin.controller;

import com.syscom.admin.service.SysRoleService;
import com.syscom.common.base.BasePage;
import com.syscom.common.entity.SysRole;
import com.syscom.common.utils.result.AjaxResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author wjz
 * @Date 2021-01-01
 */
@RestController
@RequestMapping("/sysRole")
public class SysRoleController {

    @Autowired
    private SysRoleService sysRoleService;

    @ApiOperation("SysRole查询接口")
    @GetMapping("/querySysRole")
    public AjaxResult querySysRole(BasePage basePage, String name) {

        return sysRoleService.querySysRole(basePage, name);
    }

    @ApiOperation("SysRole新增接口")
    @PostMapping("/addSysRole")
    public AjaxResult addSysRole(@RequestBody SysRole sysRole) {

        return sysRoleService.addSysRole(sysRole);
    }

    @ApiOperation("SysRole更新接口")
    @PatchMapping("/updateSysRole/{objectId}")
    public AjaxResult updateSysRole(@PathVariable Long objectId, @RequestBody SysRole sysRole) {

        sysRole.setObjectId(objectId);
        return sysRoleService.updateSysRole(sysRole);
    }

    @ApiOperation("SysRole删除接口")
    @DeleteMapping("/deleteSysRole/{objectId}")
    public AjaxResult deleteSysRole(@PathVariable Long objectId) {

        return sysRoleService.deleteSysRole(objectId);
    }

}

